home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Web Graphics with Shout 3D
/
Interactive Web Graphics With Shout 3D.iso
/
mac
/
Code
/
Chapter Code.exe
/
Chapter09
/
SwingPanel.java
< prev
next >
Wrap
Text File
|
2000-07-06
|
1KB
|
58 lines
package applets;
import shout3d.*;
import shout3d.core.*;
import shout3d.math.*;
public class SwingPanel extends Shout3DPanel implements RenderObserver{
Transform t;
float cycleAngle = 0;
float limit = 3.0f;
float cycleTime = 4.0f; //seconds per cycle
public SwingPanel (Shout3DApplet applet){
super(applet);
}
public void customInitialize() {
getRenderer().addRenderObserver(this, null);
t = (Transform) getNodeByName("trans");
}
protected void finalize() {
getRenderer().removeRenderObserver(this);
}
public void onPreRender (Renderer r, Object o) {
//change in angle around cycle
float deltaAngle = (6.28f/cycleTime)/getFramesPerSecond();
//update angle
cycleAngle = cycleAngle + deltaAngle;
//convert angle to x position
float xPos = (float) (Math.cos(cycleAngle) * limit);
//update Transform
t.translation.set1Value(0, xPos);
}
public void onPostRender (Renderer r, Object o) {
}
} //end of class